package besta.moon.sql.expression.function.numeric;

import besta.moon.sql.parser.SQLTokenizer;
import besta.moon.sql.expression.function.FunctionReturnFloat;

public final class FunctionPower extends FunctionReturnFloat {

    @Override
    public final int getFunction() {
        return SQLTokenizer.POWER;
    }

    @Override
    public boolean isNull() throws Exception {
        return param1.isNull() || param2.isNull();
    }

    @Override
    public final double getDouble() throws Exception {
        if (isNull()) {
            return 0;
        }
        return Math.pow(param1.getDouble(), param2.getDouble());
    }
}
